Skip to content

Conversation

@Flamefire
Copy link
Contributor

Type of Changes

Type
✨ New feature

Description

Add support for --known-first-party similar to --known-third-party:
Force import order to recognize a module as part of a first party library.

Based on #10802 as otherwise tests would fail

@Flamefire Flamefire force-pushed the first-party-imports branch 2 times, most recently from bd160ae to 070dac1 Compare January 6, 2026 13:03
@Flamefire Flamefire changed the title Add support for isort: known-first-party Add support for isort option --known-first-party Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (5a770e3) to head (3ba7fb8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10803   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files         176      176           
  Lines       19566    19567    +1     
=======================================
+ Hits        18781    18782    +1     
  Misses        785      785           
Files with missing lines Coverage Δ
pylint/checkers/imports.py 94.91% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pierre-Sassoulas Is this option something we want to add?

@github-actions

This comment has been minimized.

@Flamefire Flamefire force-pushed the first-party-imports branch 2 times, most recently from 270b3bd to 710916d Compare January 7, 2026 09:23
@Flamefire
Copy link
Contributor Author

Flamefire commented Jan 7, 2026

Motivation for me was that we have a project that uses a test folder and hence import test.utils etc. but test is a Python stdlib package: PyCQA/isort#2383

Rather than doing a large-scale refactoring adding this exception is the easiest way out.

It would be even better if PyLint would understand the isort config (in setup.cfg) directly so one doesn't has to duplicate it.

@github-actions

This comment has been minimized.

@Flamefire Flamefire force-pushed the first-party-imports branch from 710916d to ceba49f Compare January 9, 2026 07:41
@DanielNoord
Copy link
Collaborator

This will need a rebase, and an opinion from @Pierre-Sassoulas or any other maintainer about whether we want to do this or not

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have replacing isort by ruff on my mind but we can probably accommodate both (by adding an optional dependency and putting isort imports behind guards). Let's add isort features if the people want them, I guess ? (How much maintenance can one isort option cost ? 12 $ ?)

Similar to known-third-party this recognizes modules as first party modules.
@Flamefire Flamefire force-pushed the first-party-imports branch from ceba49f to 3ba7fb8 Compare January 11, 2026 11:18
@Flamefire
Copy link
Contributor Author

Rebased

@github-actions
Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 3ba7fb8

@DanielNoord DanielNoord merged commit 5c8062b into pylint-dev:main Jan 11, 2026
44 checks passed
@Flamefire Flamefire deleted the first-party-imports branch January 11, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants